﻿using System;
using NUnit.Framework;
using System.Text;
using System.IO;
using TelnetExpect;

namespace TelnetTests.ExpectorTests
{
    [TestFixture]
    public class RegExpectorTests
    {
        //--------
        void Create_Expector(string input, out RegExpector xp, out MemoryStream dst)
        {
            if (input == null)
                input = string.Empty;
            byte[] inputB = Encoding.ASCII.GetBytes(input);
            MemoryStream src0 = new MemoryStream(inputB, false);
            Stream src = /*this_.Create_ModifierStream(*/src0;
            dst = new MemoryStream();
            PairStream conn = new PairNoCanSeekStream(src, dst);
            xp = Create_Expector(conn);
        }

        protected virtual RegExpector Create_Expector(Stream conn)
        {
            RegExpector xp = new RegExpector(conn);
            return xp;
        }

        //--------
        [Test]
        public void Aaaa()
        {
            RegExpector xp;
            MemoryStream dst;
            string input = "result: Success";
            Create_Expector(input, out xp, out dst);
            //
            xp.Expect("result: (Success)|(Failure)");
            Assert.AreEqual("result: Success", xp.ReadDuringExpect, "ReadDuringExpect");
        }

        [Test]
        public void Aaab()
        {
            RegExpector xp;
            MemoryStream dst;
            string input = "result: Failure";
            Create_Expector(input, out xp, out dst);
            //
            xp.Expect("result: (Success)|(Failure)");
            Assert.AreEqual("result: Failure", xp.ReadDuringExpect, "ReadDuringExpect");
        }

    }
}
